import { lists, detail } from '@/services/goods';

export default {
  namespace: 'goods',

  state: {
    list: [],
  },

  effects: {
    *fetch(payload, { call, put }) {
      const response = yield call(lists, payload.payload);
      yield put({
        type: 'search',
        payload: response,
      });
    },
    *fetchDetail(payload, { call, put }) {
      const response = yield call(detail, payload.payload);
      yield put({
        type: 'search',
        payload: response,
      });
    },
  },

  reducers: {
    search(state, action) {
      return {
        ...state,
        list: action.payload,
      };
    },
  },
};
